package com.lideru.backstage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lideru.backstage.entity.Bookrack;
import com.lideru.backstage.entity.dto.dataDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BookrackMapper extends BaseMapper<Bookrack> {
    @Select("SELECT count(b.id) count, a.name FROM t_book a LEFT JOIN t_bookrack b  on a.id =  b.book_id WHERE a.user_id = #{userId} GROUP BY b.book_id ORDER BY COUNT(b.book_id) DESC ;")
    List<dataDto> countBookrack(Long userId);
}
